(function (vc) {
    vc.extends({
        data: {
            housekeepingServDetailInfo: {
                poolId: '',
                cartId: '',
                servName: '',
                applyName: '',
                applyTel: '',
                hktName: '',
                roomName: '',
                appointmentTime: '',
                context: '',
                stateName: '',
                userId: '',
                userName: '',
                housekeepingServUsers: [],
                photos: [],
                housekeepingServPhotos: [],
                beforePhotos: [],
                afterPhotos: [],
                visitType: '',
                visitContext: '',
                maintenanceType: '',
                housekeepingServMaterials: '',
                housekeepingServFee: '',
                resourceStoreInfo: []
            }
        },
        _initMethod: function () {
            let poolId = vc.getParam('poolId');
            if (!vc.notNull(poolId)) {
                vc.toast('非法操作');
                vc.jumpToPage('/#/pages/goods/housekeepingServPoolManage');
                return;
            }
            $that.housekeepingServDetailInfo.poolId = poolId;
            $that._listRepairPools()
        },
        _initEvent: function () {
        },
        methods: {
            _listRepairPools: function () {
                var param = {
                    params: {
                        page: 1,
                        row: 1,
                        shopId: vc.getCurrentCommunity().shopId,
                        poolId: $that.housekeepingServDetailInfo.poolId
                    }
                };
                //发送get请求
                vc.http.apiGet('/housekeepingServPool/queryHousekeepingServPool',
                    param,
                    function (json, res) {
                        var _housekeepingServPoolManageInfo = JSON.parse(json);
                        let _housekeepingServs = _housekeepingServPoolManageInfo.data;
                        if (_housekeepingServs.length < 1) {
                            vc.toast("数据异常");
                            vc.jumpToPage('/#/pages/goods/housekeepingServPoolManage');
                            return;
                        }
                        vc.copyObject(_housekeepingServs[0], $that.housekeepingServDetailInfo);
                        $that.housekeepingServDetailInfo.hktName = _housekeepingServs[0].housekeepingServDtos[0].hktName;
                        //查询处理轨迹
                        $that._loadRepairUser();
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _loadResourceStoreList: function () {
                var param = {
                    params: {
                        page: 1,
                        row: 100,
                        communityId: vc.getCurrentCommunity().communityId,
                        poolId: $that.housekeepingServDetailInfo.poolId
                    }
                };
                //发送get请求
                vc.http.apiGet('resourceStore.listResourceStoreUseRecords',
                    param,
                    function (json, res) {
                        var _housekeepingServResourceStoreInfo = JSON.parse(json);
                        let _resource = _housekeepingServResourceStoreInfo.data;
                        $that.housekeepingServDetailInfo.resourceStoreInfo = _resource;
                        $that.housekeepingServDetailInfo.resourceStoreInfo.forEach((item) => {
                            if (item.resId == '666666') {
                                item.rstName = item.specName = '自定义';
                            }
                        })
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _loadRepairUser: function () {
                var param = {
                    params: {
                        page: 1,
                        row: 100,
                        shopId: vc.getCurrentCommunity().shopId,
                        poolId: $that.housekeepingServDetailInfo.poolId
                    }
                };
                //发送get请求
                vc.http.apiGet('/housekeepingServPoolUser/queryHouseServPoolUser',
                    param,
                    function (json, res) {
                        var _housekeepingServPoolManageInfo = JSON.parse(json);
                        let _housekeepingServs = _housekeepingServPoolManageInfo.data;
                        $that.housekeepingServDetailInfo.housekeepingServUsers = _housekeepingServs;
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _goBack: function () {
                vc.goBack()
            },
            openFile: function (_photo) {
                vc.emit('viewImage', 'showImage', {
                    url: _photo.url
                });
            }
        }
    });
})(window.vc);
